package com.topcoder.srm515;

public class RotatedClock {
	public String getEarliest(int hourHand, int minuteHand) {
		int k = hourHand - minuteHand;
		for (int hour = 0; hour < 12; hour++) {
			for (int minute = 0; minute < 60; minute++) {
				if ((30*hour - 5.5*minute - k)%360 == 0 && (minuteHand - 6*minute)%30 == 0) {
					return String.format("%02d:%02d", hour, minute);
				}
			}
		}
		return "";
	}
}
